package solver;

import java.util.Iterator;

import ilog.concert.IloException;
import ilog.concert.IloNumVar;
import ilog.cplex.IloCplex;
import tools.Vector;
import uncertainty.UncertaintySet;

/**
 * @class VariableMapping
 * 
 * This class represents a mapping for the variables used to build up 
 * the diferrent problems in this code.
 * 
 * @author Marcio Costa Santos
 * @see VariableMapping
 */
public class VariableMappingSimple extends VariableMapping {

	/**
	 * @Constructor
	 * 
	 * @param dim
	 * @param k
	 * */
	public VariableMappingSimple(int dim, int k) {
		super(dim, k);
	}

	@Override
	/**
	 * @method initialize
	 * 
	 * @param UncertaintySet us
	 * @param  Ilocplex cplex
	 * */
	public void initialize(UncertaintySet us, IloCplex cplex) throws IloException {
		Iterator<Vector<Double>> it = us.extremePoints();
		Vector<Double> elem;
		StrucRecXiT data;
		IloNumVar[] var;
		
		while(it.hasNext()){
			elem = it.next();
			for(int i = 0; i < n; i++){
				data = new StrucRecXiT(elem.getProjection(i - k), i);
				if(!map.contains(data)){
					var = new IloNumVar[1];
					var[0] = cplex.numVar(0, Double.MAX_VALUE);
					map.put(data, var);
				}
			}
			it.remove();
		}

	}

}
